<template>
	<view class="detail">
		<!-- 头部导航 -->
		<view class="w-750" style="position: fixed; top: 0; left: 0; z-index: 999;">
			<view class="h-100 w-row-justify-between-align">
				<view class="wh-80 w-row-center" @click="routerBack()">
					<image class="wh-40" src="../../../static/gane/goBack-white-icon.png"></image>
				</view>
				<view class="flex1 h-100 w-row-center w-wz-conts font-36 text-color-white">
					<text>红包信息</text>
				</view>
				<view class="wh-80 w-row-center">
					<!-- <uni-datetime-picker type="datetimerange" @change="changeTiem">
	  				<image class="wh-50" src="../../../static/gane/rq.png"></image>
	  			</uni-datetime-picker> -->
				</view>
			</view>
		</view>
		<view class="bwh-120"></view>
		<!-- 头部导航结束 -->

		<view class="hongbao-title-bg">
			<view class="ba-top">
			</view>
			<view class="ba-bot">
			</view>

			<view class="cent">
				<view class="title">
					<view class="avatar">
						<view class="van-image">
							<image :src="info.headimgurl" class="van-image__img"
								v-if="info.headimgurl"></image>
							<image src="@/static/gane/user.png" class="van-image__img" v-else></image>
						</view>
					</view>
					<view class="name">
						{{info.nickname}}的红包
					</view>
				</view>

				<view class="price-box">
					金额 <span>{{info.money}}</span><span v-if="info.type==3">- 雷{{info.leiNumber}}</span>
				</view>
			</view>
		</view>

		<view class="cent-box">
			<view class="total">
				共 <span>{{info.endNumber}}/{{info.number}}</span> 个红包
			</view>

			<view class="item" v-for="(item,index) in info.orderList" :key="index">
				<image :src="item.headimgurl" class="profile-img" v-if="item.headimgurl"></image>
				<image src="@/static/gane/user.png" class="profile-img" v-else></image>

				<view class="title">
					<view class="name">
						<view class="tips" v-if="info.userId==item.userId">
							庄
						</view>
						{{item.nickname}}
						<!-- <div class="tipsY" v-if="item.userId == userInfo.uid">自己</div> -->
					</view>

					<view class="time">
						{{item.createtime}}
					</view>
				</view>
				<view class="outcome">
					<view class="outcome-title">
						胜负
					</view>
					<view v-if="item.game_type=='1'">

						<view class="price" v-if="item.status==1">
							{{item.amoney}}
						</view>
						<view class="price" v-if="item.status==2">
							-{{info.money}}
						</view>
            <view class="price" v-if="item.status==0">
              <span v-if="item.userId==userInfo.uid"> {{item.amoney}}</span>
              <span v-else>--</span>
            </view>
					</view>
					<view v-else>

            <view class="price" v-if="info.status==1">
              {{item.income_amount}}
            </view>
            <view class="price" v-else>
              --
            </view>
					</view>
				</view>
				<view class="outcome">
					<view class="outcome-title">
						抢包
					</view>
					<view class="price" v-if="info.status==1">
						{{item.amoney}}
					</view>
          <view class="price" v-else>
            <span v-if="item.userId==userInfo.uid"> {{item.amoney}}</span>
            <span v-else>--</span>
          </view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import $H from '@/pages/common/request.js'
	export default {
		data() {
			return {
				id: null,
				info: {},
				time: null,
				userInfo: {}
			}
		},
		onLoad(option) {
			this.id = option.id;
      //this.settlement();
			this.getInfo();

		},
		mounted() {
			this.getUserInfo()
			this.time = setInterval(() => {
				this.getInfo()

			}, 3000)
		},
		onUnload() {
			if (this.time) {
				clearInterval(this.time);
				this.time = null;
			}
		},
		methods: {
			getUserInfo() {
				$H.post('/app_user_get_userinfo').then((res) => {
					if (res.code == 200) {
						this.userInfo = res.data

						uni.setStorageSync('UserInfo', res.data)
					}
				})
			},
			settlement() {
				$H.post('/app_red_envelope_settlement', {
					id: this.id
				}).then((res) => {

					if (res.code == 200) {


					}
				})
			},

			getInfo() {
				$H.post('/app_red_envelope_info', {
					id: this.id
				}).then((res) => {
					console.log(res, 'getRoom');
					if (res.code == 200) {
						this.info = res.data;
						if (res.data.status == 1) {
              this.settlement();
							clearInterval(this.time);
							this.time = null;
						}
					}
				})
			}
		}
	};
</script>

<style lang="scss" scoped>
	body {
		background-color: #f0f3ff !important;
	}

	uni-page-body {
		background-color: transparent;
	}

	.text-color-white {
		color: #fff !important;
	}
	
	.tips{
		font-size: 14rpx;
		background: #f4af00;
		border-radius: 100%;
		width: 26rpx;
		height: 26rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		color: #fff;
		margin-left: 4rpx;
		margin-top: 6rpx;
	}
	
	.tipsY{
		font-size: 14rpx;
		background: #f4af00;
		border-radius: 4rpx;
		width: 44rpx;
		height: 30rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		color: #fff;
		margin-left: 4rpx;
		// margin-top: 4rpx;
	}

	.hongbao-title-bg {
		position: fixed;
		left: 0;
		right: 0;
		top: 0;
		height: 400rpx;
    z-index:111;

		.ba-top {
			width: 100%;
			height: 230rpx;
			background-color: #f75d51;
			position: absolute;
		}

		.ba-bot {
			position: absolute;
			width: 100%;
			height: 230rpx;
			background-color: #f75d51;
			left: 0;
			border-radius: 100%;
			bottom: 60rpx;
		}

		.cent {
			position: relative;
			z-index: 1;

			.title {
				display: flex;
				align-items: center;
				justify-content: center;
				padding-top: 140rpx;

				.avatar {
					width: 40rpx;
					height: 40rpx;
				}

				.name {
					color: #efe491;
					font-size: 30rpx;
					margin-left: 10rpx;
				}
			}

			.price-box {
				margin-top: 40rpx;
				color: #efe491;
				font-size: 30rpx;
				display: flex;
				align-items: center;
				justify-content: center;

				&>span {
					margin-left: 20rpx;
				}
			}

		}
	}

	.cent-box {
		margin-top: 260rpx;

		.total {

			padding: 0 20rpx;
			padding-bottom: 16rpx;
			color: #939390;
			font-size: 24rpx;
			border-bottom: 1px solid #e5e3e375;
		}

		.item {
			padding: 26rpx 20rpx;
			border-bottom: 1px solid #e5e3e375;
			display: flex;
			align-items: center;
			color: #939390;
			font-size: 24rpx;

			.profile-img {
				width: 80rpx;
				height: 80rpx;
			}

			.title {
				width: 0;
				flex: 1;
				margin-left: 20rpx;

				.name {
					display: flex;
					align-items: center;

					.tips {
						width: auto;
						padding: 3rpx 6rpx;
						font-size: 20rpx;
						color: #fff;
						background-color: #f3c75e;
						border-radius: 6rpx;
						margin-right: 8rpx;
					}
				}

				.time {
					margin-top: 6rpx;
				}
			}

			.outcome {
				width: 17%;
				// margin-left: 50rpx;
				text-align: right;

				.price {
					margin-top: 6rpx;
				}
			}
		}
	}
</style>